package com.example.layui.controller;

import com.example.layui.pojo.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Controller;

import java.security.Principal;

@Controller
public class GreetingController {

    //   /app/hello
    @MessageMapping("/hello")
    @SendTo("/topic/greetings")
    public Message hello(Principal principal, Message message){
        message.setName(principal.getName());
        return message;
    }


}
